<?php
	class function_global{
		function huruf2angka($obj1) {
			switch ($obj1) {
				case "A" : { return 4; break; }
				case "AB" :{ return 3.5; break; }
				case "B" :{ return 3; break; }
				case "BC" :{ return 2.5; break; }
				case "C" :{ return 2; break; }
				case "D" :{ return 1; break; }
				case "E" :{ return 0; break; }
				default : { return 0; break; }
			}
		}
		
		function ips2sks($obj1, $obj2_mhs_baru = false){
			if ($obj1 < 1.500) {
				$obj3_limitsks = 12;
			}
			if (($obj1 >= 1.500) and ($obj1 < 1.750)) {
				$obj3_limitsks = 14;
			}
			if (($obj1 >= 1.750) and ($obj1 < 2.000)) {
				$obj3_limitsks = 16;
			}
			if (($obj1 >= 2.000) and ($obj1 < 2.250)) {
				$obj3_limitsks = 18;
			}
			if (($obj1 >= 2.250) and ($obj1 < 3.000)) {
				$obj3_limitsks = 21;
			}
			if ($obj1 >= 3.000) {
				$obj3_limitsks = 24;
			}
			
			if( $obj2_mhs_baru ){
				$obj3_limitsks = 24;
			}
			
			return $obj3_limitsks;
		}
		
		function periodelama2periodensemester($obj1_periode){
			$obj_big = new stdClass;
			$obj_big->semester = (substr($obj1_periode,0,1) == 1 ? "GASAL" : "GENAP");
			$obj_small1 = (substr($obj1_periode,2,2) > 90) ? "19".substr($obj1_periode,2,2) : "20".substr($obj1_periode,2,2);
			$obj_small2 = (substr($obj1_periode,5,2) > 90) ? "19".substr($obj1_periode,5,2) : "20".substr($obj1_periode,5,2);
			$obj_big->periode = $obj_small1.'-'.$obj_small2;
			return $obj_big;
		}
		
		function pagu2kuotakelas($obj1_pagu){
			if ($obj1_pagu->pagu == 0) {
				return " - ";
			} else {
				return "Maksimal ".$obj1_pagu." mahasiswa";
			}
		}
	}
	
	$function = new function_global();
	
	//special function
	
	$urutan_sort_nilai_huruf = array('A','AB','B','BC','C','D','E','BL');	
	function sort_nilai_huruf($a, $b){
	   global $urutan_sort_nilai_huruf;
	   $pos1=array_search ($a[nilai], $urutan_sort_nilai_huruf);
	   $pos2=array_search ($b[nilai], $urutan_sort_nilai_huruf);
	   if ($pos1==$pos2)
		   return 0;
	   else
		  return ($pos1 < $pos2 ? -1 : 1);
	}
?>